package com.eis.performacetest.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.log4j.Logger;

public class PropertyReader {
	private static Properties P_TEST_PROPERTIES = new Properties();
	private static Logger logger = Logger.getLogger(PropertyReader.class);
	
	static {
		// load properties
		InputStream in = ClassLoader.getSystemResourceAsStream("performancetest.properties");
		try {
			P_TEST_PROPERTIES.load(in);
		} catch (IOException e) {
			logger.error("Error when loading performancetest.properties. \r\n", e);
		}
	}
	
	public static int getTCorePoolSize() {
		return Integer.parseInt(P_TEST_PROPERTIES.getProperty("threadpool.corePoolSize"));
	}
	
	public static int getTMaximumPoolSize() {
		return Integer.parseInt(P_TEST_PROPERTIES.getProperty("threadpool.maximumPoolSize"));
	}
	
	public static int getTKeepAliveTime() {
		return Integer.parseInt(P_TEST_PROPERTIES.getProperty("threadpool.keepAliveTime"));
	}
	
	public static int getTConcurrentThreads() {
		return Integer.parseInt(P_TEST_PROPERTIES.getProperty("threadpool.concurrentThreads"));
	}
	
	public static String getTCallurl() {
		return P_TEST_PROPERTIES.getProperty("testThread.callurl");
	}
	
	public static int getTRepeatTime() {
		return Integer.parseInt(P_TEST_PROPERTIES.getProperty("testThread.repeatTime"));
	}
	
	public static int getTRequestSleepTime() {
		return Integer.parseInt(P_TEST_PROPERTIES.getProperty("testThread.requestSleepTime"));
	}
}
